package Messages;

import java.io.IOException;
import java.sql.SQLException;

import ocsf.server.ConnectionToClient;
import server.SQLConnection;
/**
 * This class implements the edit private card to DB
 * @author Gabi Revah
 * @author Aviad Almog
 */ 
public class MessageEditPrivate {
	private ConnectionToClient client ;
	private String[] str; 
	static int row1;
/**
 * Contractor of this class 
 * @param str
 * @param client
 */
	public MessageEditPrivate(String[] str, ConnectionToClient client){
		
		this.client= client ;
		this.str= str; 	
	
	}
/**
 * This method edit the private card detailed in the DB 
 * @throws SQLException
 * @throws IOException
 */
	
	public void EditPrivate() throws SQLException, IOException{
	
				SQLConnection sc = new SQLConnection();
				
				java.sql.PreparedStatement ps = sc.getConnection().prepareStatement("Update DB.private SET firstname=?,lastname=?,address=?,email=?,phone=? WHERE idprivate=?");
		

				
				ps.setString(1, str[2]);
				ps.setString(2, str[3]);
				ps.setString(3, str[4]);
				ps.setString(4, str[5]);
				ps.setString(5, str[6]);
				ps.setString(6, str[1]);

				
				
				ps.executeUpdate();
				client.sendToClient("Editprivate");

				ps.close();
				
	}

}
